import 'dart:convert';
import 'package:flutter/services.dart';

class MockApi {
  /// 通用 JSON 加载方法
  static Future<Map<String, dynamic>> _loadJson(String path) async {
    try {
      // await Future.delayed(const Duration(milliseconds: 200));
      final jsonString = await rootBundle.loadString(path);
      return json.decode(jsonString) as Map<String, dynamic>;
    } catch (e) {
      throw Exception('Failed to load JSON: $path');
    }
  }

  // 轮播图
  static Future<Map<String, dynamic>> fetchBanner() async {
    final jsonData = await _loadJson('assets/mock/banner.json');
    return jsonData;
  }

  // 推荐歌单模块
  static Future<Map<String, dynamic>> fetchRecommendPlayList() async {
    final jsonData = await _loadJson('assets/mock/recommend_play_list.json');
    return jsonData;
  }

  // 推荐mv模块
  static Future<Map<String, dynamic>> fetchRecommendMvList() async {
    final jsonData = await _loadJson('assets/mock/recommend_mv_list.json');
    return jsonData;
  }

  // 用户信息
  // static Future<Map<String, dynamic>> fetchUser() async {
  //   final jsonData = await _loadJson('assets/mock/user.json');
  //   return jsonData;
  // }
}
